package com.linchaoen.elema.service.impl;

import com.linchaoen.elema.config.CacheKeyManager;
import com.linchaoen.elema.mapper.CartMapper;
import com.linchaoen.elema.model.entity.Cart;
import com.linchaoen.elema.model.entity.Store;
import com.linchaoen.elema.service.CartService;
import com.linchaoen.elema.utils.BaseCache;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class CartServiceImpl implements CartService {

    @Autowired
    private CartMapper cartMapper;

    @Autowired
    private BaseCache baseCache;

    @Override
    public List<Cart> findCartByUserId(Integer userId) {
        return cartMapper.findCartListByUserId(userId);
    }

    @Override
    @Transactional
    public int addCart(Integer userId, Integer foodId, Integer num) {
        return cartMapper.addCart(userId, foodId, num);
    }

    @Override
    public int addCartBatch(Integer userId, List<Cart> list) {
        return cartMapper.addCartBatch(userId, list);
    }

    @Override
    public int removeCart(Integer uid, Integer id) {
        return cartMapper.removeCart(uid, id);
    }

    @Override
    public int changeNum(Integer uid, Integer id, Integer num) {
        return cartMapper.changeNum(uid, id, num);
    }


}
